par(ask=FALSE)
par(mfrow=c(1,1))

par(mfrow=c(2,1))
abline.lwd <- 2
abline.lty <- 2
line.lwd <- 3

plot(x=my.steps, y=observed.Recdf,
     main = "Observed 1-ECDF vs. 1-Estimated ECDF",    
     xlab = "Execution time",
     ylab = "P[ExecTime > X]",
     ylim = c(0,1),   
     lwd = line.lwd,
     pch = 1,
     type="l"
)

lines( x = my.steps, y = estimated.Recdf, 		
       type = "l", 
       lwd = 3,
       pch = 1,
       col = "red"
)

legend("topright",
       legend = c("Observed 1-ECDF", "Estimated 1-ECDF", "Observed quantiles", "Estimated quantiles"), 
       col = c("black", "red", "green", "blue"), 
       text.col = "black", 
       bg = "white",
       lty = c(1, 1, abline.lty, abline.lty), 
       lwd=c(line.lwd,line.lwd, abline.lwd, abline.lwd),
       title="Legend", 
       bty='o', 
       title.adj=0.50,
	     cex=0.8 #text size
)

abline(v=estimated.q95, col="blue", lwd=abline.lwd, lty=abline.lty)
text(estimated.q95, 0.9, " q = 95%", lty=3, col = "gray40", adj = c(0, -.1))

abline(v=estimated.q99, col="blue", lwd=abline.lwd, lty=abline.lty)
text(estimated.q99, 0.8, " q = 99%", lty=3, col = "gray40", adj = c(0, -.1))

abline(v=observed.q95, col="green", lwd=abline.lwd, lty=abline.lty)
text(observed.q95, 0.5, " q = 95%", lty=3, col = "gray40", adj = c(0, -.1))

abline(v=observed.q99, col="green", lwd=abline.lwd, lty=abline.lty)
text(observed.q99, 0.4, " q = 99%", lty=3, col = "gray40", adj = c(0, -.1))

## Zoom in

plot(x=my.steps, y=observed.Recdf,
     main = "Observed 1-ECDF vs. 1-Estimated ECDF (Zoomed in)",    
     xlab = "Execution time",
     ylab = "P[ExecTime > X]",
     xlim = c(observed.q95,  observed.q100),
     ylim = c(0,0.05),   
     lwd = line.lwd,
     pch = 1,
     type="l"
)

legend("topright",
       legend = c("Observed 1-ECDF", "Estimated 1-ECDF", "Observed quantiles", "Estimated quantiles"), 
       col = c("black", "red", "green", "blue"), 
       text.col = "black", 
       bg = "white",
       lty = c(1, 1, abline.lty, abline.lty), 
       lwd=c(line.lwd,line.lwd, abline.lwd, abline.lwd),
       title="Legend", 
       bty='o', 
       title.adj=0.50,
	   cex=0.8 #text size
)

lines( x = my.steps, y = estimated.Recdf,   	
       type = "l", 
       lwd = 3,
       pch = 1,
       col = "red"
)

abline(v=estimated.q95, col="blue", lwd=abline.lwd, lty=abline.lty)
text(estimated.q95, 0.9, " q = 95%", lty=3, col = "gray40", adj = c(0, -.1))
abline(v=estimated.q99, col="blue", lwd=abline.lwd, lty=abline.lty)
text(estimated.q99, 0.8, " q = 99%", lty=3, col = "gray40", adj = c(0, -.1))
abline(v=observed.q95, col="green", lwd=abline.lwd, lty=abline.lty)
text(observed.q95, 0.5, " q = 95%", lty=3, col = "gray40", adj = c(0, -.1))
abline(v=observed.q99, col="green", lwd=abline.lwd, lty=abline.lty)
text(observed.q99, 0.4, " q = 99%", lty=3, col = "gray40", adj = c(0, -.1))

